<template>
	<view class="page_forget">
		<!-- input输入框 -->
		<view class="input-group">
			<view class="input-row border-bottom">
				<image class="img" src="/static/login/phone.png" mode="widthFix"></image>
				<input class="input" type="text" v-model="oldpassword" placeholder="请输入原密码"
					placeholder-style="color:rgba(0,0,0,0.45);font-size:30rpx;" />
			</view>
			<view class="input-row border-bottom">
				<image class="img" src="/static/login/pw.png" mode="widthFix"></image>
				<input class="input" type="text" v-model="newpassword" placeholder="请设置新密码" maxlength="12"
					placeholder-style="color:rgba(0,0,0,0.45);font-size:30rpx;" />
			</view>
			<view class="input-row border-bottom">
				<image class="img" src="/static/login/pw.png" mode="widthFix"></image>
				<input class="input" type="text" v-model="newrewpassword" placeholder="请再次输入新密码" maxlength="12"
					placeholder-style="color:rgba(0,0,0,0.45);font-size:30rpx;" />
			</view>
		</view>
		<view class="login-btn">
			<view class="subtn"><button type="primary" @click="rforgetPasswdClick">提交</button></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldpassword: '',
				newpassword: '',
				newrewpassword: ''
			};
		},
		onLoad() {},
		methods: {
			rforgetPasswdClick() {
				if (!this.oldpassword) {
					uni.showToast({
						icon: 'none',
						title: '请输入旧密码'
					})
					return
				}
				if(!this.newpassword){
					uni.showToast({
						title: '请输入新密码',
						icon: 'none'
					})
					return
				}
				if(this.newpassword != this.newrewpassword){
					uni.showToast({
						title: '两次密码不一致',
						icon: 'none'
					})
					return
				}
				this.$http('user.savepassword', {
					newpassword: this.newpassword,
					oldpassword: this.oldpassword,
				}, '修改中...').then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: '密码重置成功',
							icon: 'none'
						});
						uni.removeStorageSync('token');
						setTimeout(time => {
							uni.reLaunch({
								url: '/pages/login/login/login'
							})
						}, 1000);
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						});
					}
				})
			}
		}
	};
</script>

<style lang="scss">
	.page {
		background-color: #F6F7F9;
	}

	/*input输入框*/
	.input-group {
		padding: 0upx 24upx;
		background-color: #fff;

		.input-row {
			position: relative;
			height: 96upx;
			display: flex;
			align-items: center;

			.img {
				width: 34rpx;
				height: 34rpx;
				margin-right: 30upx;
			}

			.input {
				width: 65%;
				font-size: 32rpx;
				margin-left: 20rpx;
				font-size: 30rpx;
				font-family: PingFang-SC-Medium, PingFang-SC;
				font-weight: 500;
				color: rgba(0, 0, 0, 0.85);
			}
		}

		.input-row.border-bottom {
			border-bottom: 1rpx solid #EEEEEE;
		}
	}



	/*登录按钮*/
	.login-btn {
		width: 686rpx;
		position: fixed;
		bottom: 50rpx;
		left: 50%;
		transform: translate(-50%);

		.subtn {
			button {
				height: 98px;
				background: linear-gradient(93deg, #6FAD19 0%, #287E34 100%);
				width: 100%;
				height: 98rpx;
				text-align: center;
				line-height: 90rpx;
				border-radius: 49rpx;
				font-size: 32rpx;
				font-weight: 500;
				border: none;
				color: #fff;
			}
		}
	}
</style>